package org.zfes.snowier.cloud.zbss.loan.wx.controller;


import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.auth.biz.service.IAuthUserService;
import org.zfes.snowier.auth.shiro.util.SecurityUtil;
import org.zfes.snowier.common.dao.params.ParamMap;
import org.zfes.snowier.core.data.DataSet;

import java.util.Map;
import java.util.Optional;

@Controller("WeiChatAccountController")
@RequestMapping("/pub/member/WeiChatAccount")
public class WeiChatAccountController {

    @Autowired
    private IAuthUserService authUserService;

    //分销商信息列表
    @RequestMapping(value = "/loadDistributionUserInfoDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody Object loadInfoUserDataSet(@RequestParam Map<String, Object> params) {
        JSONObject responsResult = new JSONObject();
        return responsResult;
    }

    //修改密码
    @RequestMapping(value = "/updateAuthUserPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody Object updateAuthUserPassword(@RequestParam Map<String, Object> params) {
        JSONObject responsResult = new JSONObject();
        ParamMap pm = ParamMap.filterParam(params);
        Optional<String> newPassword = pm.getStr("newPassword");
        Optional<String> oldPassword = pm.getStr("oldPassword");
        if(newPassword.isPresent() && oldPassword.isPresent()){
            Long userId = SecurityUtil.getUserId().get();
            //String passwordNew = ShiroMD5EndecryptUtil.genSetp1Password(newPassword.get());
           // String passwordOld = ShiroMD5EndecryptUtil.genSetp1Password(oldPassword.get());
           // authUserService.changePwd(userId, passwordNew, passwordOld);
            //responsResult.put(CloudStockConst.WebControllerResult.CODE,CloudStockConst.WebControllerCode.STATUS_CODE_200);
        }else{
            //responsResult.put(CloudStockConst.WebControllerResult.CODE,CloudStockConst.WebControllerCode.STATUS_CODE_201);
        }
        return responsResult;
    }
}
